package com.ryan;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONObject;

public class Test {
	
	public void writer(String json){
		Writer writer = null;
		try{
			writer = new FileWriter(new File("D:/android/20131218/UnicomConsume_new.uwc"));
			writer.write(json);
		}catch(Exception e){
			
		}finally{
			if(writer != null){
				try {
					writer.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

	public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {
		System.out.println("##############");
//		BufferedReader reader = null;
//		try{
//			reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File("D:/android/20131218/UnicomConsume_old.uwc")),
//					"utf-8"));
//			StringBuffer sb = new StringBuffer();
//			String content = null;
//			while((content = reader.readLine()) != null){
//				sb.append(content);
//			}
//			JSONObject json = new JSONObject(sb.toString());
////			System.out.println(json.toString());
//			String cpInfoStr = json.getString("cpinfo");
//			System.out.println(cpInfoStr);
//			JSONObject cpInfoJson = new JSONObject(cpInfoStr);
//			String cpCode = cpInfoJson.getString("cp_code");
//			String cpId = cpInfoJson.getString("cp_id");
//			System.out.println("cp_code:"+cpInfoJson.get("cp_code"));
//			System.out.println("cp_id:"+cpInfoJson.get("cp_id"));
//			cpInfoJson.put("cp_code", cpId);
//			cpInfoJson.put("cp_id", cpCode);
//			json.put("cpinfo", cpInfoJson);
//			System.out.println("cp_code:"+cpInfoJson.get("cp_code"));
//			System.out.println("cp_id:"+cpInfoJson.get("cp_id"));
////			System.out.println(cpInfoJson.toString());
//			Test test = new Test();
//			test.writer(json.toString());	
//			
//		}catch(Exception e){
//			e.printStackTrace();
//		}
//		finally{
//			if(reader != null){
//				try {
//					reader.close();
//				} catch (IOException e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}
//			}
//		}
		HttpClient client = new DefaultHttpClient();
		System.out.println("@@@@@@@@@@@@@");
	}
}
